import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/4/29
 */
public class Demo18 {
    static int N = 100010;
    static int n,m;
    static int[] a = new int[N];
    static int[] s = new int[N];

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int n = scan.nextInt();        int m = scan.nextInt();


        for(int i = 1; i <= n; i++) a[i] = scan.nextInt();

        for(int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];

        while(true){
            if(m-- == 0)break;
            int l,r;
            l = scan.nextInt();r = scan.nextInt();
            System.out.println(s[r] - s[l - 1]);
        }
    }
}
